//
//  BaoXianTableViewCell.m
//  wangzhe
//
//  Created by 李 佳伟 on 2017/11/3.
//  Copyright © 2017年 李 佳伟. All rights reserved.
//

#import "BaoXianTableViewCell.h"
#import "JTCSM.h"
static CGFloat space = 20;
static CGFloat viewHeight = 98;

@implementation BaoXianTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self  = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.backgroundColor = RGBACOLOR(241,241,241,1);
        UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(space, space, KSCREENWidth-2*space, viewHeight)];
        backview.backgroundColor = [UIColor whiteColor];
        backview.userInteractionEnabled = YES;
        [df layerWithView:backview radius:3 width:0 color:nil];
        [self.contentView addSubview:backview];
        CGFloat changespace = 10;
        self.statusImageView = [[UIImageView alloc]initWithFrame:CGRectMake(backview.frame.size.width-viewHeight-space+2*changespace, changespace, viewHeight-2*changespace, viewHeight-2*changespace)];
        [self.statusImageView setImage:[UIImage imageNamed:@"bg_04.png"]];
        [self.statusImageView setHighlightedImage:[UIImage imageNamed:@"bg_06.png"]];
        [backview addSubview:self.statusImageView];
        
        CGFloat yuanviewsize = 15;
        
        UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(-(yuanviewsize/2), viewHeight*2/3-yuanviewsize/2, yuanviewsize, yuanviewsize)];
        [df layerWithView:view1 radius:yuanviewsize/2 width:0 color:nil];
        view1.backgroundColor = self.contentView.backgroundColor;
        [backview addSubview:view1];
        
        UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(backview.frame.size.width-(yuanviewsize/2), viewHeight*2/3-yuanviewsize/2, yuanviewsize, yuanviewsize)];
        [df layerWithView:view2 radius:yuanviewsize/2 width:0 color:nil];
        view2.backgroundColor = self.contentView.backgroundColor;
        [backview addSubview:view2];
        CGFloat titlebleSpace = 10;
        self.titleLabel = [UILabel initWithFrame:CGRectMake(titlebleSpace, 0, self.statusImageView.frame.origin.x-titlebleSpace, viewHeight/3) text:@"王者管家账户安全险" font:16 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
        [backview addSubview:self.titleLabel];
        
        self.contentLabel = [UILabel initWithFrame:CGRectMake(titlebleSpace, viewHeight/3-5, self.statusImageView.frame.origin.x-titlebleSpace, viewHeight/3) text:@"王者管家账户安全险" font:14 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, .7) backgroundColor:nil];
        [backview addSubview:self.contentLabel];
        
        self.timeLabel = [UILabel initWithFrame:CGRectMake(titlebleSpace, viewHeight*2/3, backview.frame.size.width, viewHeight/3) text:@"2017-10-31-2018-10-31" font:14 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, .7) backgroundColor:nil];
        [backview addSubview:self.timeLabel];
        
    }
    
    return self;
}

- (void)setValueWithBaoxinModel:(BaoxianModel *)model{
    if (model == nil) {
        return;
    }
    
    self.titleLabel.text = model.title;
    self.contentLabel.text = model.company;
    self.timeLabel.text = [NSString stringWithFormat:@"保险期限%@-%@",model.use_start,model.use_end];
    if ([model.status integerValue] == 1) {
        self.statusImageView.highlighted = NO;
    }else{
        self.statusImageView.highlighted = YES;
    }
}

@end
